New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@feathersjs/feathers

Package Overview
Dependencies
Maintainers
3
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@feathersjs/feathers

A framework for real-time applications and REST API with JavaScript and TypeScript

  • 5.0.32
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
81K
increased by0.69%
Maintainers
3
Weekly downloads
 
Created

What is @feathersjs/feathers?

@feathersjs/feathers is a lightweight web framework for building real-time applications and REST APIs using JavaScript or TypeScript. It provides a flexible architecture for creating services that can be used on the client and server, making it easy to build scalable and maintainable applications.

What are @feathersjs/feathers's main functionalities?

Service Creation

This code demonstrates how to create a basic service in FeathersJS. The service has methods for finding, getting, and creating messages. The service is then registered with the Feathers application and used to create a new message.

const feathers = require('@feathersjs/feathers');
const app = feathers();

// A simple service that logs and returns the message
class MessageService {
  async find() {
    return [];
  }

  async get(id) {
    return { id, text: `A new message with ID: ${id}` };
  }

  async create(data) {
    return data;
  }
}

app.use('messages', new MessageService());

app.service('messages').create({ text: 'Hello Feathers' }).then(message => {
  console.log('Created message', message);
});

Hooks

This code shows how to use hooks in FeathersJS. Hooks are middleware functions that can be run before or after a service method. In this example, a 'before' hook is used to log the data before a message is created.

const feathers = require('@feathersjs/feathers');
const app = feathers();

// A simple service
class MessageService {
  async create(data) {
    return data;
  }
}

app.use('messages', new MessageService());

// A hook that logs the data before creating a message
app.service('messages').hooks({
  before: {
    create: async context => {
      console.log('Creating message', context.data);
    }
  }
});

app.service('messages').create({ text: 'Hello Feathers' });

Real-time Functionality

This code demonstrates how to add real-time functionality to a FeathersJS application using Socket.io. The application is configured to use Socket.io, and a service is created that publishes events to all connected clients whenever a new message is created.

const feathers = require('@feathersjs/feathers');
const socketio = require('@feathersjs/socketio');
const app = feathers();

app.configure(socketio());

// A simple service
class MessageService {
  async create(data) {
    return data;
  }
}

app.use('messages', new MessageService());

app.on('connection', connection =>
  app.channel('everybody').join(connection)
);

app.publish(data => app.channel('everybody'));

app.service('messages').create({ text: 'Hello Feathers' });

Other packages similar to @feathersjs/feathers

Keywords

FAQs

Package last updated on 01 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc